<include file="public/layout" />
<!--物流配置 css -start-->
<script src="__ROOT__/public/static/js/layer/laydate/laydate.js"></script>
<style>
    ul.group-list {
        width: 96%;min-width: 1000px; margin: auto 5px;list-style: disc outside none;
    }
    .err{color:#F00; display:none;}
    ul.group-list li {
        white-space: nowrap;float: left;
        width: 150px; height: 25px;
        padding: 3px 5px;list-style-type: none;
        list-style-position: outside;border: 0px;margin: 0px;
    }
    .row .table-bordered td .btn,.row .table-bordered td img{
        vertical-align: middle;
    }
    .row .table-bordered td{
      padding: 8px;
      line-height: 1.42857143;
    }
    .table-bordered{
      width: 100%
    }
    .table-bordered tr td{
      border: 1px solid #f4f4f4;
    }
    .btn-success {
        color: #fff;background-color: #449d44;border-color: #398439 solid 1px;
    }
    .btn {
        display: inline-block;
        padding: 6px 12px;
        margin-bottom: 0;
        font-size: 14px;
        font-weight: 400;
        line-height: 1.42857143;
        text-align: center;
        white-space: nowrap;
        vertical-align: middle;
        -ms-touch-action: manipulation;
        touch-action: manipulation;
        cursor: pointer;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
        background-image: none;
        border: 1px solid transparent;
        border-radius: 4px;
    }
    .col-xs-8 {
        width: 66.66666667%;
    }
    .col-xs-4 {
        width: 33.33333333%;
    }
    .col-xs-1, .col-xs-10, .col-xs-11, .col-xs-12, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9 {
        float: left;
    }
    .row .tab-pane h4{
      padding: 10px 0;
    }
    .row .tab-pane h4 input{
      vertical-align: middle;
    }
    .table-striped>tbody>tr:nth-of-type(odd) {
        background-color: #f9f9f9;
    }
    .ncap-form-default .title{
      border-bottom: 0
    }
    .ncap-form-default dl.row, .ncap-form-all dd.opt{
        border: none;
    }
    .ncap-form-default dl.row:hover, .ncap-form-all dd.opt:hover{
        border: none;box-shadow: inherit;
    }
    .addprine{display: inline; }
    .alisth{margin-top: 10px}
    .p_plus strong{cursor: pointer;margin-left: 4px;}
</style>
<!--物流配置 css -end-->
<!--以下是在线编辑器 代码 -->
<load href="__ROOT__/public/plugins/Ueditor/ueditor.config.js"/>
<load href="__ROOT__/public/plugins/Ueditor/ueditor.all.min.js"/>
<script type="text/javascript" charset="utf-8" src="__ROOT__/public/plugins/Ueditor/lang/zh-cn/zh-cn.js"></script>
<!--以上是在线编辑器 代码  end-->
<body style="background-color: #FFF; overflow: auto;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>矿机设置</h3>
                <h5>矿机基本信息设置</h5>
            </div>
            <ul class="tab-base nc-row">
                <li><a onclick="change_tab(this)" data-index='1' class="tab current"><span>通用信息</span></a></li>
            </ul>
        </div>
    </div>
    <!-- 操作说明 -->
    <div class="explanation" id="explanation">
        <div class="title" id="checkZoom"><i class="fa fa-lightbulb-o"></i>
            <h4 title="提示相关设置操作时应注意的要点">操作提示</h4>
            <span id="explanationZoom" title="收起提示"></span> </div>
        <ul>
            <li>请务必正确填写商品信息</li>
        </ul>
    </div>
    <!--表单数据-->
    <form method="post" id="addEditGoodsForm">
        <input type="hidden" value="{$Request.param.is_distribut}" name="is_distribut" class="input-txt"/>
        <input type="hidden" name="item_id" value="{$minerInfo.item_id}">
<!--通用信息-->
        <div class="ncap-form-default tab_div_1">
            <dl class="row">
                <dt class="tit">
                    <label for="record_no">矿机名称</label>
                </dt>
                <dd class="opt">
                    <input type="text" value="{$minerInfo.miner_name}" name="miner_name" class="input-txt"/>
                    <span class="err" id="err_miner_name" style="color:#F00; display:none;"></span>
                </dd>
            </dl>

            <if condition="($minerInfo.type eq 1) or (empty($minerInfo.miner_id) eq true)">
                <dl class="row">
                    <dt class="tit">
                        <label for="record_no">售价</label>
                    </dt>
                    <dd class="opt">
                        <input type="text" value="{$minerInfo.miner_price}" name="miner_price" class="input-txt" onKeyUp="this.value=this.value.replace(/[^\d.]/g,'')" onpaste="this.value=this.value.replace(/[^\d.]/g,'')" />
                        <span class="err" id="err_miner_price" style="color:#F00; display:none;"></span>
                    </dd>
                </dl>
            </if>

           <!-- <dl class="row">
                <dt class="tit">
                    <label for="record_no">Token</label>
                </dt>
                <dd class="opt">
                    <input type="text" name="token" value="{$minerInfo.token}" class="input-txt" onKeyUp="this.value=this.value.replace(/[^\d.]/g,'')" onpaste="this.value=this.value.replace(/[^\d.]/g,'')" />
                    <span class="err" id="err_miner_price" style="color:#F00; display:none;"></span>
                </dd>
            </dl>-->

            <dl class="row">
                <dt class="tit">
                    <label for="record_no">最小购买量</label>
                </dt>
                <dd class="opt">
                    <input type="text" name="min" value="{$minerInfo.min}" placeholder="请输入最小购买量" class="input-txt" onKeyUp="this.value=this.value.replace(/[^\d.]/g,'')" onpaste="this.value=this.value.replace(/[^\d.]/g,'')" />
                    <span class="err" id="min" style="color:#F00; display:none;"></span>
                </dd>
            </dl>

            <dl class="row">
                <dt class="tit">
                    <label for="record_no">最大购买量</label>
                </dt>
                <dd class="opt">
                    <input type="text" name="max" value="{$minerInfo.max}" placeholder="请输入最大购买量" class="input-txt" onKeyUp="this.value=this.value.replace(/[^\d.]/g,'')" onpaste="this.value=this.value.replace(/[^\d.]/g,'')" />
                    <span class="err" id="max" style="color:#F00; display:none;"></span>
                </dd>
            </dl>

            <dl class="row">
                <dt class="tit">
                    <label for="record_no">倍数</label>
                </dt>
                <dd class="opt">
                    <input type="text" name="multiple" value="{$minerInfo.multiple}" placeholder="请输入倍数" class="input-txt" onKeyUp="this.value=this.value.replace(/[^\d.]/g,'')" onpaste="this.value=this.value.replace(/[^\d.]/g,'')" />
                    <span class="err" id="multiple" style="color:#F00; display:none;"></span>
                </dd>
            </dl>

            <dl class="row">
                <dt class="tit">
                    <label for="record_no">Token释放速度</label>
                </dt>
                <dd class="opt">
                    <input type="text" name="token_speed" value="{$minerInfo.token_speed}" class="input-txt" onKeyUp="this.value=this.value.replace(/[^\d.]/g,'')" onpaste="this.value=this.value.replace(/[^\d.]/g,'')" />
                    <span class="err" id="err_miner_price" style="color:#F00; display:none;"></span>
                </dd>
            </dl>

            <!--<dl class="row">
                <dt class="tit">
                    <label for="record_no">产量</label>
                </dt>
                <dd class="opt">
                    <input type="text" value="{$minerInfo.release}" name="release" class="input-txt" onKeyUp="this.value=this.value.replace(/[^\d]/g,'')" onpaste="this.value=this.value.replace(/[^\d]/g,'')" />
                    <span class="err" id="err_miner_price" style="color:#F00; display:none;"></span>
                    <p class="notic">产量值 单位：时</p>
                </dd>
            </dl>-->

           <!-- <dl class="row" id="release_size_row">
                <dt class="tit">
                    <label for="miner_size" id="miner_size_text">矿机算力</label>
                </dt>
                <dd class="opt">
                    <input type="text" id="miner_size" value="{$minerInfo.miner_size}" name="miner_size" class="input-txt" onKeyUp="this.value=this.value.replace(/[^\d.]/g,'')" onpaste="this.value=this.value.replace(/[^\d.]/g,'')" />
                    <span class="err" id="err_release_size" style="color:#F00; display:none;"></span>
                </dd>
            </dl>-->

            <!--<dl class="row">
                <dt class="tit">
                    <label for="record_no">失效时间</label>
                </dt>
                <dd class="opt">
                    <input type="text" value="{$minerInfo.scrap_days}" name="scrap_days" class="input-txt" onKeyUp="this.value=this.value.replace(/[^\d.]/g,'')" onpaste="this.value=this.value.replace(/[^\d.]/g,'')" />
                    <span class="err" id="err_miner_price" style="color:#F00; display:none;"></span>
                    <p class="notic">矿机报废时间，注：如未返回也会强制报废  单位：时</p>
                </dd>
            </dl>-->

            <!--<dl class="row">
                <dt class="tit">
                    <label for="record_no">购买算力值条件</label>
                </dt>
                <dd class="opt">
                    <input type="text" value="{$minerInfo.buy_condition}" name="buy_condition" class="input-txt" onKeyUp="this.value=this.value.replace(/[^\d.]/g,'')" onpaste="this.value=this.value.replace(/[^\d.]/g,'')" />
                    <span class="err" id="err_miner_price" style="color:#F00; display:none;"></span>
                    <p class="notic">注：请填写整数</p>
                </dd>
            </dl>-->
            <dl class="row">
                <dt class="tit">
                    <label for="record_no">静态玩家数量限制</label>
                </dt>
                <dd class="opt">
                    <input type="text" value="{$minerInfo.static_user_limit}" name="static_user_limit" class="input-txt" onKeyUp="this.value=this.value.replace(/[^\d.]/g,'')" onpaste="this.value=this.value.replace(/[^\d.]/g,'')" />
                    <span class="err" id="err_miner_price" style="color:#F00; display:none;"></span>
                    <p class="notic">注：请填写整数</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label for="record_no">大型矿机玩家数量限制</label>
                </dt>
                <dd class="opt">
                    <input type="text" value="{$minerInfo.big_user_limit}" name="big_user_limit" class="input-txt" onKeyUp="this.value=this.value.replace(/[^\d.]/g,'')" onpaste="this.value=this.value.replace(/[^\d.]/g,'')" />
                    <span class="err" id="err_miner_price" style="color:#F00; display:none;"></span>
                    <p class="notic">注：请填写整数</p>
                </dd>
            </dl>

            <dl class="row">
                <dt class="tit">
                    <label>是否赠送</label>
                </dt>
                <dd class="opt">
                    <div class="onoff">
                        <label for="switch1" class="cb-enable  <if condition="$minerInfo['type'] eq 2">selected</if>">是</label>
                        <label for="switch2" class="cb-disable <if condition="$minerInfo['type'] eq 1">selected</if>">否</label>
                        <input type="radio" onclick="$('#switch_on_off').show();"  id="switch1"  name="type" value="2" <if condition="$minerInfo['type'] eq 2">checked="checked"</if>>
                        <input type="radio" onclick="$('#switch_on_off').hide();" id="switch2" name="type" value="1" <if condition="$minerInfo['type'] eq 1">checked="checked"</if> >
                    </div>
                </dd>
            </dl>

            <dl class="row">
                <dt class="tit">
                    <label>图片上传</label>
                </dt>
                <dd class="opt">
                    <div class="input-file-show">
            <span class="show">
                <a id="img_a" target="_blank" class="nyroModal" rel="gal" href="{$minerInfo.original_img}">
                    <i id="img_i" class="fa fa-picture-o" onMouseOver="layer.tips('<img src={$minerInfo.original_img}>',this,{tips: [1, '#fff']});" onMouseOut="layer.closeAll();"></i>
                </a>
            </span>
            <span class="type-file-box">
                <input type="text" id="imagetext" name="original_img" value="{$minerInfo.original_img}" class="type-file-text">
                <input type="button" name="button" id="button1" value="选择上传..." class="type-file-button">
                <input class="type-file-file" onClick="GetUploadify(1,'','miner','img_call_back')" size="30" hidefocus="true" nc_type="change_site_logo" title="点击前方预览图可查看大图，点击按钮选择文件并提交表单后上传生效">
            </span>
                    </div>
                    <span class="err"></span>
                    <p class="notic">请上传图片格式文件</p>
                </dd>
            </dl>

        </div>
		<div class="ncap-form-default">
            <div class="bot">
                <input type="hidden" name="miner_id" value="{$minerInfo.miner_id}">
                <input type="hidden" name="__token__" value="{$Request.token}" />
                <a href="JavaScript:void(0);" onclick="verifyForm()" class="ncap-btn-big ncap-btn-green" id="submitBtn">确认提交</a>
            </div>
        </div>
     </form>
    <!--表单数据-->
</div>
<div id="goTop"> <a href="JavaScript:void(0);" id="btntop"><i class="fa fa-angle-up"></i></a><a href="JavaScript:void(0);" id="btnbottom"><i class="fa fa-angle-down"></i></a></div>
<script>
    //选择矿机类型
    var type = "{$minerInfo.type}";
    sel_type(type);
    function sel_type(type){
        if(type==2){
            $("#max_price_row").hide();
            $("#release_size_row").hide();

        }else{
            $("#max_price_row").hide();
            $("#release_size_text").text('矿机算力');
        }
    }
    //选择分类
    $(function(){
        $(document).on("change",'#cat_id',function(){
            get_category($(this).val(),'cat_id_2','0');
            $('#cat_id_3').empty().html("<option value='0'>请选择商品分类</option>");
        })
    })
    $(function(){
        $(document).on("change",'#extend_cat_id',function(){
            get_category($(this).val(),'extend_cat_id_2','0');
            $('#extend_cat_id_3').empty().html("<option value='0'>请选择商品分类</option>");
        })
    })
    $(function(){
        $(document).on("click",'.is_virtual',function(){
            initIsVirtual();
        })
    })
    // 物流设置相 关
     $(document).ready(function(){
        $(":checkbox[cka]").click(function(){
            var $cks = $(":checkbox[ck='"+$(this).attr("cka")+"']");
            if($(this).is(':checked')){
                $cks.each(function(){$(this).prop("checked",true);});
            }else{
                $cks.each(function(){$(this).removeAttr('checked');});
            }
        });
    });

     var url="{:url('Admin/Ueditor.Ueditor/index',array('savePath'=>'goods'))}";
     var ue = UE.getEditor('goods_content',{
         serverUrl :url,
         zIndex: 999,
         initialFrameWidth: "100%", //初化宽度
         initialFrameHeight: 300, //初化高度
         focus: false, //初始化时，是否让编辑器获得焦点true或false
         maximumWords: 99999, removeFormatAttributes: 'class,style,lang,width,height,align,hspace,valign',//允许的最大字符数 'fullscreen',
         pasteplain:false, //是否默认为纯文本粘贴。false为不使用纯文本粘贴，true为使用纯文本粘贴
         autoHeightEnabled: true
     });

    // 物流设置相 关
    function choosebox(o){
        var vt = $(o).is(':checked');
        if(vt){
            $('input[type=checkbox]').prop('checked',vt);
        }else{
            $('input[type=checkbox]').removeAttr('checked');
        }
    }
    /*
     * 以下是图片上传方法
     */
    // 上传商品图片成功回调函数
    function call_back(fileurl_tmp){
        $("#original_img").val(fileurl_tmp);
    	$("#original_img2").attr('href', fileurl_tmp);
    }

    // 上传商品相册回调函数
    function call_back2(paths){

        var  last_div = $(".goods_xc:last").prop("outerHTML");
        for (var i=0;i<paths.length ;i++ )
        {
            $(".goods_xc:eq(0)").before(last_div);	// 插入一个 新图片
                $(".goods_xc:eq(0)").find('a:eq(0)').attr('href',paths[i]).attr('onclick','').attr('target', "_blank");// 修改他的链接地址
            $(".goods_xc:eq(0)").find('img').attr('src',paths[i]);// 修改他的图片路径
                $(".goods_xc:eq(0)").find('a:eq(1)').attr('onclick',"ClearPicArr2(this,'"+paths[i]+"')").text('删除');
            $(".goods_xc:eq(0)").find('input').val(paths[i]); // 设置隐藏域 要提交的值
        }
    }
    /*
     * 上传之后删除组图input
     * @access   public
     * @val      string  删除的图片input
     */
    function ClearPicArr2(obj,path)
    {
    	$.ajax({
                    type:'GET',
                    url:"{:U('Admin/Ueditor.Uploadify/delupload')}",
                    data:{action:"del", filename:path},
                    success:function(){
                           $(obj).parent().remove(); // 删除完服务器的, 再删除 html上的图片
                    }
		});
		// 删除数据库记录
    	$.ajax({
                    type:'GET',
                    url:"{:U('Admin/Goods.Goods/del_goods_images')}",
                    data:{filename:path},
                    success:function(){
                          //
                    }
		});
    }


/** 以下 商品属性相关 js*/

// 属性输入框的加减事件
function addAttr(a)
{
	var attr = $(a).parent().parent().prop("outerHTML");
	attr = attr.replace('addAttr','delAttr').replace('+','-');
	$(a).parent().parent().after(attr);
}
// 属性输入框的加减事件
function delAttr(a)
{
   $(a).parent().parent().remove();
}




/** 以下是编辑时默认选中某个商品分类*/
$(document).ready(function(){

	<if condition="$level_cat['2'] gt 0">
		 // 商品分类第二个下拉菜单
		 get_category('{$level_cat[1]}','cat_id_2','{$level_cat[2]}');
	</if>
	<if condition="$level_cat['3'] gt 0">
		// 商品分类第二个下拉菜单
		 get_category('{$level_cat[2]}','cat_id_3','{$level_cat[3]}');
	</if>

    //  扩展分类
	<if condition="$level_cat2['2'] gt 0">
		 // 商品分类第二个下拉菜单
		 get_category('{$level_cat2[1]}','extend_cat_id_2','{$level_cat2[2]}');
	</if>
	<if condition="$level_cat2['3'] gt 0">
		// 商品分类第二个下拉菜单
		 get_category('{$level_cat2[2]}','extend_cat_id_3','{$level_cat2[3]}');
	</if>

});


    $(document).ready(function(){
        //插件切换列表
        $('.tab-base').find('.tab').click(function(){
//            $('.tab-base').find('.tab').each(function(){
//                $(this).removeClass('current');
//            });
//            $(this).addClass('current');
            $(this).addClass('current').siblings().removeClass('current');
			var tab_index = $(this).data('index');
			$(".tab_div_1, .tab_div_2, .tab_div_3, .tab_div_4,.tab_div_5").hide();
			$(".tab_div_"+tab_index).show();
		});

    });

    function img_call_back(fileurl_tmp)
    {
        $("#imagetext").val(fileurl_tmp);
        $("#img_a").attr('href', fileurl_tmp);
        $("#img_i").attr('onmouseover', "layer.tips('<img src="+fileurl_tmp+">',this,{tips: [1, '#fff']});");
    }

    function initIsVirtual(){
        var goods_id = $("input[name='goods_id']").val();
        var is_virtual;
        if(goods_id > 0){
            is_virtual = $("input[name='is_virtual']").val();
        }else{
            is_virtual = $("input[name='is_virtual']:checked").val();
        }
        if(is_virtual == 1){
            $('.virtual').show();
        }else{
            $('.virtual').hide();
        }
    }
    function change_tab(that){
        $('.tab').removeClass('current');
        $(that).addClass('current');
    }
    function selectGoods(){
        var url = "{:U('Promotion.Promotion/search_goods',array('tpl'=>'select_goods','prom_type'=>2))}";
        layer.open({
            type: 2,
            title: '选择商品',
            shadeClose: true,
            shade: 0.2,
            area: ['75%', '75%'],
            content: url,
        });
    }

    function call_back(goodsItem){
        $('#goods_id').val(goodsItem.goods_id);
        var html = '';
        if(goodsItem.spec != null){
            //有规格
            html = '<div style="float: left;margin: 10px auto;" class="selected-group-goods"><div class="goods-thumb">' +
                '<img style="width: 162px;height: 162px" src="'+goodsItem.spec.spec_img+'"/></div> <div class="goods-name"> ' +
                '<a target="_blank" href="/index.php?m=Home&c=Goods&a=goodsInfo&id='+goodsItem.goods_id+'">'+goodsItem.goods_name+goodsItem.spec.key_name+'</a> </div>' +
                ' <div class="goods-price">商城价：￥'+goodsItem.spec.price+'库存:'+goodsItem.spec.store_count+'</div> </div>';
            $('input[name=item_id]').val(goodsItem.spec.item_id)
            $('input[name=goods_name]').val(goodsItem.goods_name + goodsItem.spec.key_name);
        }else{
            html = '<div style="float: left;margin: 10px auto;" class="selected-group-goods"><div class="goods-thumb">' +
                '<img style="width: 162px;height: 162px" src="'+goodsItem.goods_image+'"/></div> <div class="goods-name"> ' +
                '<a target="_blank" href="/index.php?m=Home&c=Goods&a=goodsInfo&id='+goodsItem.goods_id+'">'+goodsItem.goods_name+'</a> </div>' +
                ' <div class="goods-price">商城价：￥'+goodsItem.goods_price+'库存:'+goodsItem.store_count+'</div> </div>';
            $('input[name=goods_name]').val(goodsItem.goods_name);
        }
        $('#select_goods_button').attr('data-goods-id',goodsItem.goods_id);
        $('#selected_group_goods').empty().html(html);
        $('.selected-group-goods').show();
        layer.closeAll('iframe');
    }


    function verifyForm(){

        $.ajax({
            type: "POST",
            url: "{:U('World.Miner/editMill?is_ajax=1')}",
            data: $('#addEditGoodsForm').serialize(),
            dataType: "json",
            error: function () {
                layer.alert("服务器繁忙, 请联系管理员!");
            },
            success: function (data) {
                if (data.status == 1) {
                    layer.msg(data.msg, {icon: 1, time: 1000}, function(){
                        window.location.href=data.data.url;
                    });
                }else{
                    layer.msg(data.msg, {icon: 2, time: 1000}, function(){
                        // window.location.href=data.data.url;
                    });
                }
            }
        });
    }
</script>
</body>
</html>
